package com.frost.demo.ioc.controller;

import com.frost.demo.ioc.config.UserConfig;
import com.frost.demo.ioc.model.UserInfo;
import com.frost.demo.ioc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

@Controller
public class UserController {

//    @Autowired
//    private UserService userService;

//    private UserService userService;
//    private UserConfig userConfig;
//
//    public UserController() {
//    }
//
//    public UserController(UserService userService) {
//        this.userService = userService;
//    }
//
//    @Autowired
//    public UserController(UserService userService, UserConfig userConfig) {
//        this.userService = userService;
//        this.userConfig = userConfig;
//    }

//    private UserService userService;
//
//    @Autowired
//    public void setUserService(UserService userService) {
//        this.userService = userService;
//    }
//
//    public void sayHi() {
//        System.out.println("hi, UserController");
//        userService.sayHi();
//    }


//    @Qualifier(value = "userInfo2")
//    @Autowired
//    private UserInfo userInfo;

    @Resource(name = "u1")
    private UserInfo userInfo;

    public void sayHi() {
        System.out.println("hi, UserController");
        System.out.println(userInfo);
    }
}
